package com.zk.service;

import com.zk.entity.User;
import com.zk.repo.UserRepo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;


//由 Junit 4 启动 Mockito
@RunWith(MockitoJUnitRunner.class)
@AutoConfigureRestDocs
public class UserServiceTest_2 {


    @Spy
    private UserRepo userRepo = new UserRepo();

    @InjectMocks
    private UserService userService;

    // final 修饰的方法测试
    @Test
    public void testGetUser() {
        User user = userService.getUser(1);
        Assert.assertEquals(user.getId(), new Integer(1));
    }


    // final 修饰的方法测试
    @Test
    public void testFound() {
        boolean result = userService.found();
        Assert.assertEquals(false, result);
    }
}
